﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Linq;

namespace QuanLyKTX
{
    using Telerik.WinControls;
    using DAL;
    using Utilities;

    public partial class frm_ReportEWBill : Telerik.WinControls.UI.RadForm
    {

        public List<tbl_HoaDonDienNuoc> ListHoaDonDienNuoc { get; set; }

        public frm_ReportEWBill()
        {
            InitializeComponent();
            ListHoaDonDienNuoc = null;
        }

        public frm_ReportEWBill(List<tbl_HoaDonDienNuoc> hoaDonDN)
        {
            InitializeComponent();
            ListHoaDonDienNuoc = hoaDonDN;
        }

        private void frm_ReportEWBill_Load(object sender, EventArgs e)
        {
            using (var db = new QuanLyKTXDataContext())
            {
                foreach (var hoaDon in ListHoaDonDienNuoc)
                {
                    DataRow dr       = dataSetHoaDonDienNuoc.Tables[0].NewRow();
                    dr["SoPhong"]    = hoaDon.SoPhong;
                    dr["TuNgay"]     = hoaDon.TuNgay;
                    dr["DenNgay"]    = hoaDon.DenNgay;
                    dr["CSDienCuoi"] = hoaDon.CSDienCuoi;
                    dr["CSDienDau"]  = hoaDon.CSDienDau;
                    dr["CSNuocCuoi"] = hoaDon.CSNuocCuoi;
                    dr["CSNuocDau"]  = hoaDon.CSNuocDau;
                    dr["DonGiaDien"] = hoaDon.DonGiaDien;
                    dr["DonGiaNuoc"] = hoaDon.DonGiaNuoc;
                    dr["KyThang"]    = hoaDon.KyThang;
                    dr["Nam"]        = hoaDon.Nam;
                    dr["GhiChu"]     = hoaDon.GhiChu;

                    dataSetHoaDonDienNuoc.Tables[0].Rows.Add(dr);
                }

                reportViewer_EWBill.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet_HoaDonDienNuoc", dataSetHoaDonDienNuoc.Tables[0]));
                reportViewer_EWBill.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
                reportViewer_EWBill.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.PageWidth;
                this.reportViewer_EWBill.RefreshReport();
            }
        }
    }
}
